package jtyrian.screen;

import com.badlogic.gdx.scenes.scene2d.InputEvent;
import jtyrian.Tyrian;

import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import jtyrian.util.DefaultActorListener;

public class MenuScreen
        extends AbstractScreen {
    // setup the dimensions of the menu buttons

    private static final float BUTTON_WIDTH = 300f;
    private static final float BUTTON_HEIGHT = 60f;
    private static final float BUTTON_SPACING = 10f;

    public MenuScreen(
            Tyrian game) {
        super(game);
    }

    @Override
    public void resize(
            int width,
            int height) {
        super.resize(width, height);

        // retrieve the default table actor
        Table table = super.getTable();
        table.add("Welcome to Tyrian for Android!").spaceBottom(50);
        table.row();

        // register the button "start game"
        TextButton startGameButton = new TextButton("Start game", getSkin());
        startGameButton.addListener(new DefaultActorListener() {
            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                super.touchUp(event, x, y, pointer, button);
                game.setScreen(new StartGameScreen(game));
            }
        });
        table.add(startGameButton).size(300, 60).uniform().spaceBottom(10);
        table.row();


        // register the button "options"
        TextButton optionsButton = new TextButton("Options", getSkin());
        optionsButton.addListener(new DefaultActorListener() {
            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                super.touchUp(event, x, y, pointer, button);
                game.setScreen(new OptionsScreen(game));
            }
        });
        table.add(optionsButton).uniform().fill().spaceBottom(10);
        table.row();

        // register the button "high scores"
        TextButton highScoresButton = new TextButton("High Scores", getSkin());
        highScoresButton.addListener(new DefaultActorListener() {
            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                super.touchUp(event, x, y, pointer, button);
                game.setScreen(new HighScoresScreen(game));
            }
        });
        table.add(highScoresButton).uniform().fill();



    }
}